package com.cn.example;

import java.util.concurrent.*;

public class TestThreadPool {

    private ThreadPoolExecutor threadPoolExecutor;
    private BlockingQueue<Runnable> queue;

    public TestThreadPool() {
        this.queue = new LinkedBlockingQueue<>();
        this.threadPoolExecutor = new ThreadPoolExecutor(2, 5, 1, TimeUnit.MINUTES, queue);
    }

    public void submit(String a) {
        TestPool testPool = new TestPool(a);
        this.threadPoolExecutor.submit(testPool);
    }

    public static void main(String[] args) {

    }

    class TestPool implements Runnable {
        private String a;

        public TestPool(String a) {
            this.a = a;
        }


        @Override
        public void run() {
            System.out.println("-->" + this.a);
        }
    }
}
